#!/bin/bash

read -p "please input you want to monitor server's ip address :" m_ip
read -p "please input you want to  monitor port number:" m_port
while :
do
	if nc -w 2 -z $m_ip $m_port ;then 
		echo -e "\e[32m $m_ip $m_port is open\e[0m"
	else
		echo -e "\e[31m $m_ip $m_port is closed\e[0m"
	fi
	sleep 1
done
